package sj.System.dao.impl;

import org.mybatis.spring.SqlSessionTemplate;
import sj.System.dao.sysUser.SysUserMapper;
import sj.System.pojo.SysUser;

import java.util.List;

public class SysUserMapperImpl implements SysUserMapper {

    private SqlSessionTemplate sqlSession;
    public SqlSessionTemplate getSqlSession() {
        return sqlSession;
    }

    public void setSqlSession(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }

    /**
     * 增加
     *
     * @param sysUser
     * @return
     */
    @Override
    public int addSysUser(SysUser sysUser) {
        return sqlSession.update("sj.System.dao.sysUser.SysUserMapper.addSysUser",sysUser);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public int delSysUser(Integer id) {
        return sqlSession.update("sj.System.dao.sysUser.SysUserMapper.delSysUser",id);
    }

    /**
     * 修改
     *
     * @param sysUser
     * @return
     */
    @Override
    public int updateSysUser(SysUser sysUser) {
        return sqlSession.update("sj.System.dao.sysUser.SysUserMapper.updateSysUser",sysUser);
    }

    /**
     * 根据角色id删除用户信息
     *
     * @param roleId
     * @return
     */
    @Override
    public int delUser(Integer roleId) {
        return sqlSession.update("sj.System.dao.sysUser.SysUserMapper.delUser",roleId);
    }

    /**
     * 根据角色id查询用户信息
     *
     * @param roleId
     */
    @Override
    public List<SysUser> findUserByRoleId(Integer roleId) {
        return sqlSession.selectList("sj.System.dao.sysUser.SysUserMapper.findUserByRoleId",roleId);
    }

}
